package com.xinke.module.system.mapper.logger;

import java.util.*;

import com.xinke.component.common.pojo.PageResult;
import com.xinke.component.mybatis.mybatis.core.query.LambdaQueryWrapperExt;
import com.xinke.component.mybatis.mybatis.core.mapper.BaseMapperExt;
import com.xinke.module.system.model.entity.logger.OperateLogDO;
import org.apache.ibatis.annotations.Mapper;
import com.xinke.module.system.model.vo.logger.*;

/**
 * 操作日志记录 V2 版本 Mapper
 *
 * @author yzx
 */
@Mapper
public interface OperateLogMapper extends BaseMapperExt<OperateLogDO> {

    default PageResult<OperateLogDO> selectPage(OperateLogPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperExt<OperateLogDO>()
                .eqIfPresent(OperateLogDO::getTraceId, reqVO.getTraceId())
                .eqIfPresent(OperateLogDO::getUserId, reqVO.getUserId())
                .eqIfPresent(OperateLogDO::getUserType, reqVO.getUserType())
                .eqIfPresent(OperateLogDO::getOperateType, reqVO.getOperateType())
                .likeIfPresent(OperateLogDO::getOperateName, reqVO.getOperateName())
                .eqIfPresent(OperateLogDO::getBizId, reqVO.getBizId())
                .eqIfPresent(OperateLogDO::getOperateContent, reqVO.getOperateContent())
                .eqIfPresent(OperateLogDO::getOperateSuccess, reqVO.getOperateSuccess())
                .eqIfPresent(OperateLogDO::getOperateExtra, reqVO.getOperateExtra())
                .eqIfPresent(OperateLogDO::getRequestMethod, reqVO.getRequestMethod())
                .eqIfPresent(OperateLogDO::getRequestUrl, reqVO.getRequestUrl())
                .eqIfPresent(OperateLogDO::getUserIp, reqVO.getUserIp())
                .eqIfPresent(OperateLogDO::getUserAgent, reqVO.getUserAgent())
                .orderByDesc(OperateLogDO::getLogId));
    }

}